﻿namespace CSharPro._1009;

public class Demo
{
    public void Test1()
    {
        Console.WriteLine("1000以内的水仙花数有：");
        for (int num = 100; num < 1000; num++)
        {
            int hundreds = num / 100;
            int tens = (num / 10) % 10;
            int units = num % 10;

            if (Math.Pow(hundreds, 3) + Math.Pow(tens, 3) + Math.Pow(units, 3) == num)
            {
                Console.Write(num + " ");
            }
        }

        Console.WriteLine("\n");
    }

    public void Test2(){ 
        Console.WriteLine("100以内的质数有：");
        for (int num = 2; num < 100; num++)
        {
            bool isPrime = true;
            
            for (int i = 2; i <= Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                Console.Write(num + " ");
            }
        }

        Console.WriteLine();
    }
}